<?php
# This file is part of "Central heating manager".

# "Central heating manager" is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# "Central heating manager" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with "Central heating manager".  If not, see <http://www.gnu.org/licenses/>.




function affModes($params){

	// Récupération des paramètres
	$suffix = $params['suffix'];
	$horaires = array_key_exists('horaires', $params) ? $params['horaires'] : false;
	$modeid = array_key_exists('modeid', $params) ? $params['modeid'] : 0;
	$heure = $params['heure'];
	
	// Récupération des modes à afficher
	$modes = getModes(array('manuel' => $horaires));

	// Affichage du groupe de champs
	echo '<fieldset id="modes" data-role="controlgroup" data-mini="true" data-type="horizontal">';
	
		// Affichage du champ de saisie de l'heure
		echo $horaires ? '<input style="width:55px; float:left" type="time" tabindex="1" name="heure'.$suffix.'" id="heure'.$suffix.'" value="'.$heure.'">' : '';

		// Affichage du choix des modes
		foreach($modes as $id => $mode){
			$radioname = 'modeid'.$suffix;
			$radioid = $radioname.'_'.$id;
			
			echo '<input type="radio" name="'.$radioname.'" id="'.$radioid.'" value="'.$id.'"'.($id == $modeid ? 'checked="checked"' : '').' />';
			echo '<label for="'.$radioid.'"><img src="img/'.$id.'_color.png"></label>';
		}
		
	echo '</fieldset>';
}

function affListeNum($debut, $fin, $valeur){
	$list = '<option value=""></option>';
	for($i = $debut; $i <= $fin; $i++){
		$list .= '<option value="'.$i.'"'.($i == $valeur ? " selected" : "").'>'.$i.'</option>';
	}
	
	return $list;
}